<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- <meta name="viewport" content="width=500"> -->
    <!-- device 设备   width 宽度 -->
    <!-- <meta name="viewport" content="width=device-width"> -->
    <!-- initial 初始化   scale 比例 -->
    <!-- <meta name="viewport" content="initial-scale=2" /> -->
    <!-- <meta name="viewport" content="width=500, initial-scale=0.5"> -->
    <!-- <meta name="viewport" content="minimum-scale=1"> -->
    <!-- <meta name="viewport" content="maximum-scale=1"> -->
    <meta name="viewport" content="user-scalable=no">
    <title>Document</title>
</head>
<body>
    <div id="box">

    </div>
    <script>
        // console.log(document.documentElement.clientWidth);
        //获取元素
        let box = document.querySelector('#box');

        setInterval(() => {
            box.innerHTML = '布局视口的大小为: '
                        +document.documentElement.clientWidth 
                        + '<br>视觉视口的大小为:'
                        + window.visualViewport.width
        }, 100)
    </script>
</body>
</html>